package com.service.serviceImpl;

import com.dao.CustomerDao;
import com.dao.StudentDao;
import com.pojo.Customer;
import com.pojo.Student;
import com.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
public class CustomerServiceImpl implements CustomerService {
    @Autowired
    CustomerDao dao;
    @Autowired
    StudentDao sdao;
    List<Customer> list;
    Customer customer;

    @Override
    public List<Customer> query() {
        list= dao.query();
        return list;
    }



    @Transactional
    public void add(Customer customer, Student student) {
        dao.add(customer);
        // System.out.println(1/0);
        sdao.add(student);
    }

    @Transactional
    public void del(Integer id) {
        dao.del(id);
    }

    @Transactional
    public void update(Customer customer) {
        dao.update(customer);
    }

    @Override
    public Customer queryById(Integer id) {
        customer= dao.queryById(id);
        return customer;
    }
}
